﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace help
{
    public partial class LogForm : Form
    {
        public LogForm()
        {
            helper.logger.OnMessageAdd+=ShowMessage;
            debugbox.ScrollToCaret();
            debugbox.AddContextMenu();
            InitializeComponent();
        }

        private void DeubugClose(object sender, FormClosedEventArgs e)
        {
            helper.logger.OnMessageAdd -= ShowMessage;
        }

        //显示日志
        void ShowMessage(string message,int messagetype)
        {
            if (this == null || this.IsDisposed==true)
            {
                return;
            }

            if (!string.IsNullOrEmpty(message))
            {
                int start = debugbox.SelectionStart;
                int len = debugbox.SelectionLength;
                debugbox.AppendText(message + Environment.NewLine);
                if (len > 0)
                {
                    debugbox.Select(start, len);
                }
            }

        }

       
    }
}
